<template>
  <div class="row">
    <div class="col">
      <createdactivityVue v-if="questiontype === QuestionType.OJ" v-bind="{ ID: Number(route.query.ID), isAdmin: true }"
        :createdorupdateactivtiy="createdorupdateactivtiy" :routers="{ name: '比赛管理', query: { questiontype } }">
      </createdactivityVue>
      <createdMathActivity v-else v-bind="{ ID: Number(route.query.ID), isAdmin: true }"
        :createdorupdateactivtiy="createdorupdateactivtiy" :routers="{ name: '比赛管理', query: { questiontype } }">
      </createdMathActivity>
    </div>
  </div>
</template>
<script setup lang="ts">
import { computed, inject } from 'vue';
import { useRoute } from "vue-router";
import {
	asynccreateorupdateactivity,
} from "../../../api/index";
import createdactivityVue from '../../../components/activity/createdactivity.vue';
import createdMathActivity from '../../../components/activity/createdMathActivity.vue';
import Studycodemodel from '../../../mysql_interface/studycodemodel';
import { QuestionType } from '../../../util/data';

// 码客行
const tenant_id = inject<string | undefined>('tenant_id', undefined)

const route = useRoute()
// 路由传递过来 
const questiontype = computed(() => {
  console.log(route.query.questiontype, 'questiontype')
  return Number(route.query.questiontype || QuestionType.OJ)
})

async function createdorupdateactivtiy(data: {
	data: Studycodemodel.Iactivity;
	question: Studycodemodel.Imatchquestion[];
	teamid?: number | undefined;
	users: Studycodemodel.Iuser[],
	tenant_id?: string | null,
}) {
	data.data = { ...data.data, tenant_id }
	return asynccreateorupdateactivity({ ...data, tenant_id })
}


</script>

<style scoped>
.container-xl {
	background-color: #fff;
	margin: 0;
}

.row1 {
	margin-top: 24px;
	margin-bottom: 24px;
	font-weight: 700;
	font-size: 18px;
	line-height: 24px;
	color: var(--color-43);
}

.col1 {
	padding-left: 20px;
}
</style>